#include "comm.hpp"

#define SIZE_INFO 1024
extern Log log;

int main() {
    int shmid = createShareMem();  // 分配一段4096大小的共享内存

    char* shmaddr = (char*)shmat(shmid, NULL, 0); // 将共享内存连接到当前进程的地址空间
    if (shmaddr == (char*)-1) {
        log(Fatal, "attach share memory error");
        return -1;
    }
    log(Info, "attach share memory success");

    while(1){        
        cout << "Say@: " << shmaddr << endl;
        sleep(5);

        
    }





    // 断开共享内存
    shmdt(shmaddr);
    log(Info, "detach share memory success");

    // 删除共享内存
    shmctl(shmid, IPC_RMID, NULL);
    log(Info, "delete share memory success");

    return 0;
}